package br.com.cfccultura.admin.control.actions.prova;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.stereotype.Component;

import br.com.cfccultura.admin.control.actions.DefaultAction;
import br.com.cfccultura.admin.control.forms.prova.AgendamentoProvaForm;
import br.com.cfccultura.admin.model.enums.SimNao;
import br.com.cfccultura.admin.model.vo.AgendamentoProva;

@Component("/agendamentoProva")
public class AgendamentoProvaAction extends DefaultAction {
	
	private static final Logger logger = Logger.getLogger(AgendamentoProvaAction.class);
	
	public ActionForward atualizarResultadoProva(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {		

		AgendamentoProvaForm provaForm = (AgendamentoProvaForm) form;
		
		AgendamentoProva vo = getAgendamentoProvaDAO().consultar(provaForm.getAgendamento());
		
		vo.setAprovado(SimNao.setValue(provaForm.getAprovado()));
		vo.setRealizado(SimNao.SIM);
		vo.setUsuarioSistema(getUsuario(request));
		
		getAgendamentoProvaDAO().alterar(vo);
		
		return null;
	}

}
